home *** CD-ROM | disk | FTP | other *** search
- unit ScrollU;
-
- interface
-
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- OleCtrls, SCROLLX;
-
- type
- TForm1 = class(TForm)
- ScrollXCtrl1: TScrollXCtrl;
- ScrollXCtrl2: TScrollXCtrl;
- ScrollXCtrl3: TScrollXCtrl;
- ScrollXCtrl4: TScrollXCtrl;
- ScrollXCtrl5: TScrollXCtrl;
- procedure FormCreate(Sender: TObject);
- procedure ScrollXCtrl1OnInternalTimer(Sender: TObject);
- procedure ScrollXCtrl2OnInternalTimer(Sender: TObject);
- procedure ScrollXCtrl3OnInternalTimer(Sender: TObject);
- procedure ScrollXCtrl4OnInternalTimer(Sender: TObject);
- procedure ScrollXCtrl5OnInternalTimer(Sender: TObject);
- private
- procedure BuildGraph1;
- procedure BuildGraph2;
- procedure BuildGraph3;
- procedure BuildGraph4;
- procedure BuildGraph5;
- { Private declarations }
- public
- { Public declarations }
- end;
-
- var
- Form1: TForm1;
-
- implementation
- uses CTWXDEF;
- VAR rData1: Array[0..4] of double;
- rData2: Array[0..4] of double;
- rData3: Array[0..4] of double;
- rData4: Array[0..4] of double;
- rData5: Array[0..4] of double;
- nUpdateCounter: INTEGER;
-
- {$R *.DFM}
-
- procedure TForm1.FormCreate(Sender: TObject);
- begin
- BuildGraph1;
- BuildGraph2;
- BuildGraph3;
- BuildGraph4;
- BuildGraph5;
- end;
-
-
- procedure TForm1.BuildGraph1;
-
- begin
- ScrollXCtrl1.SDataEnable [0] := TRUE; // enable the 1st data set
- ScrollXCtrl1.SPlotType [0] := SCROLLING_LINE_GRAPH;
- ScrollXCtrl1.SDataNumGroups [0] := 4; // four channels of data
-
- rData1[0] := 2;
- rData1[1] := 4;
- rData1[2] := 6;
- rData1[3] := 8;
- //axis
- ScrollXCtrl1.AxisMax [X_AXIS1] := 25.0; // x axis from 0 - 25
- ScrollXCtrl1.AxisEnable [X_AXIS2] := TRUE; //enable the second x axis
- ScrollXCtrl1.AxisEnable [Y_AXIS2] := TRUE; //enable the second x axis
- ScrollXCtrl1.AxisMajorTickInterval [X_AXIS1] := 5.0; //label every 5 units
-
- //alarm updating
- ScrollXCtrl1.ScrollAlarmMarksEnable [0] := TRUE; //enable alarm marks
- ScrollXCtrl1.ScrollLowAlarmEnable [0] := TRUE; //enable lo alarm line
- ScrollXCtrl1.ScrollHighAlarmEnable [0] := TRUE; //enable hi alarm line
- ScrollXCtrl1.ScrollSetpointEnable [0] := TRUE; //enable set point line
-
- //title
- ScrollXCtrl1.TitleString [TITLE1] := 'Scroll Graph'; //graph title
-
- //window
- ScrollXCtrl1.WindowBackgroundColor := C_LIGHTBLUE; //background color
- ScrollXCtrl1.WindowBorderStyle := RC_HIGH;
-
- //use internal timer
- ScrollXCtrl1.EnableInternalTimer := TRUE;
-
- end;
-
-
- procedure TForm1.BuildGraph2;
- begin
- ScrollXCtrl2.SPlotType [0] := SWEEP_GRAPH; //<<constant needed for type
- ScrollXCtrl2.ScrollDirection [0] := TRUE; // vertical scrolling
- ScrollXCtrl2.ScrollDirection [1] := TRUE; // vertical scrolling
- ScrollXCtrl2.SDataEnable [0] := TRUE; // enable the 1st data set
- ScrollXCtrl2.SDataNumGroups [0] := 2; // two channels of data
- ScrollXCtrl2.SDataEnable [1] := TRUE; // enable the 2ND data set
- ScrollXCtrl2.SDataNumGroups [1] := 1; // one channels of data
-
- //axis attributes
- ScrollXCtrl2.AxisMax [Y_AXIS1] := 25.0; // Y axis from 0 - 25
- ScrollXCtrl2.AxisMajorTickInterval [Y_AXIS1] := 5.0;
-
- //font attributes for axis labels
- ScrollXCtrl2.AxisLabelFontStyle [X_AXIS1] := TEXT_BOLD;
- ScrollXCtrl2.AxisLabelFontStyle [Y_AXIS1] := TEXT_BOLD;
- ScrollXCtrl2.AxisLabelFontSize [X_AXIS1] := 10;
- ScrollXCtrl2.AxisLabelFontSize [Y_AXIS1] := 10;
- ScrollXCtrl2.AxisLabelColor [X_AXIS1] := RGB_LIGHTBLUE;
- ScrollXCtrl2.AxisLabelColor [Y_AXIS1] := RGB_LIGHTBLUE;
- rData2[0] := 10;
- rData2[1] := 15;
-
- ScrollXCtrl2.ScrollSweepLineColor [0] := RGB_LIGHTRED; // set color for sweep line
- ScrollXCtrl2.ScrollLineColor [0,0] := RGB_YELLOW;
- ScrollXCtrl2.ScrollLineColor [0,1] := RGB_WHITE;
- ScrollXCtrl2.ScrollLineColor [1,0] := RGB_BLUE;
-
- //title
- ScrollXCtrl2.TitleString [TITLE1] := 'Sweep Graph';
- ScrollXCtrl2.TitleFontStyle [TITLE1] := TEXT_BOLD;
- ScrollXCtrl2.TitleFontSize [TITLE1] := 12;
-
- ScrollXCtrl2.AxisTitleString [X_AXIS1] := 'X Axis Title';
- ScrollXCtrl2.AxisTitleString [Y_AXIS1] := 'Y Axis Title';
-
- //colors
- ScrollXCtrl2.PlotBackgroundColor := RGB_PALEBLUE;
- ScrollXCtrl2.WindowBackgroundColor := RGB_LIGHTGRAY;
-
- //plotting area
- ScrollXCtrl2.RightPlotArea := 0.92;
- ScrollXCtrl2.BottomPlotArea := 0.8;
-
- //use internal timer
- ScrollXCtrl2.EnableInternalTimer := TRUE;
- end;
-
-
- procedure TForm1.BuildGraph3;
- begin
- ScrollXCtrl3.SPlotType [0] := SCROLLING_BAR_GRAPH ; //<<constant needed for type
- ScrollXCtrl3.SDataEnable [0] := TRUE; // enable the 1st data set
- ScrollXCtrl3.ScrollRelReset [0] := 0.5; //reset to 1/2
- ScrollXCtrl3.ScrollBarWidth[0] := 0.75;
- //axis
- ScrollXCtrl3.AxisMax [Y_AXIS1] := 15.0; // y axis range -5 to 15
- ScrollXCtrl3.AxisMin [Y_AXIS1] := -5.0;
- ScrollXCtrl3.AxisMajorTickInterval [Y_AXIS1] := 5.0; //label every 5 units
- ScrollXCtrl3.AxisGridEnable [Y_AXIS1] := TRUE;
-
- rData3[0] := 7;
-
- //colors
- ScrollXCtrl3.WindowBackgroundColor := RGB_YELLOW;
-
- //title
- ScrollXCtrl3.TitleFontStyle [TITLE1] := TEXT_BOLD;
- ScrollXCtrl3.TitleString [TITLE1] := 'Scrolling Bar';
-
- //internal timer
- ScrollXCtrl3.EnableInternalTimer := TRUE;
-
- end;
-
-
- procedure TForm1.BuildGraph4;
- var
- sLegendStrings, CR: string;
- begin
- ScrollXCtrl4.SPlotType [0] := VARIABLE_SCROLLING_GRAPH; //<<constant
- ScrollXCtrl4.TitleString [TITLE1] := 'Variable Scrolling';
- ScrollXCtrl4.SDataEnable [0] := TRUE; // enable the 1st data set
- ScrollXCtrl4.SDataNumGroups [0] := 5; // Groups must = #channels + 1
- ScrollXCtrl4.AxisMax [X_AXIS1] := 50.0; // x axis from 0 - 50
-
- rData4[0] := 2;
- rData4[1] := 4;
- rData4[2] := 6;
- rData4[3] := 8;
-
- ScrollXCtrl4.ScrollLineColor[0, 0] := RGB_GREEN;
- ScrollXCtrl4.ScrollLineColor[0,1] := RGB_LIGHTMAGENTA;
- ScrollXCtrl4.ScrollLineColor[0,2] := RGB_LIGHTRED;
- ScrollXCtrl4.ScrollLineColor[0,3] := RGB_LIGHTBLUE;
-
- ScrollXCtrl4.LeftPlotArea := 0.12;
- ScrollXCtrl4.TopPlotArea := 0.3;
- ScrollXCtrl4.RightPlotArea := 0.92;
- ScrollXCtrl4.BottomPlotArea := 0.87;
-
- //legends
- CR := chr(13); // make CR a carriage return string;
- sLegendStrings := 'Boston' + CR + 'Chicago' + CR + 'Los Angeles' + CR +'Dallas' + CR;
- ScrollXCtrl4.SLegendEnable := TRUE; //must enable to view!
- ScrollXCtrl4.SLegendLeft := 0.05; //establish position
- ScrollXCtrl4.SLegendTop := 0.08;
- ScrollXCtrl4.SLegendRight := 0.95;
- ScrollXCtrl4.SLegendBottom := 0.27;
- ScrollXCtrl4.SLegendOrientation := OR_HORZ; //horizontal
- ScrollXCtrl4.SLegendFontSize := 8;
- ScrollXCtrl4.SLegendStrings := sLegendStrings;
-
- //colors
- ScrollXCtrl4.WindowBackgroundColor := RGB_MEDGRAY;
-
- //internal timer
- ScrollXCtrl4.EnableInternalTimer := TRUE;
-
- end;
-
- procedure TForm1.BuildGraph5;
- begin
- ScrollXCtrl5.SPlotType [0] := SCROLLING_XY_GRAPH; //<<constant needed for type
- ScrollXCtrl5.SDataNumGroups [0] := 4; // groups must = #channels * 2
- ScrollXCtrl5.SDataEnable [0] := TRUE; // enable the 1st data set
- ScrollXCtrl5.ScrollXYNumPoints [0] := 100; // 100 pts in the buffer
-
- nUpdateCounter := 0;
- //axis
- ScrollXCtrl5.AxisMin [X_AXIS1] := -10.0; // x axis from -10 - 10
- ScrollXCtrl5.AxisMax [X_AXIS1] := 10.0;
- ScrollXCtrl5.AxisMin [Y_AXIS1] := -10.0; // x axis from -10 - 10
- ScrollXCtrl5.AxisMax [Y_AXIS1] := 10.0;
-
- //color
- ScrollXCtrl5.WindowBackgroundColor := RGB_PALEBLUE;
-
- //title
- ScrollXCtrl5.TitleString [TITLE1] := 'XY Plot';
-
- //timer
- ScrollXCtrl5.EnableInternalTimer := TRUE;
- end;
-
-
- procedure TForm1.ScrollXCtrl1OnInternalTimer(Sender: TObject);
- var i: integer;
- begin
- For i:=0 to 3 do
- begin
- rData1[i] := rData1[i] + (0.5 - random);
- end;
- ScrollXCtrl1.UpdateDynData(0,rData1[0]);
- end;
-
- procedure TForm1.ScrollXCtrl2OnInternalTimer(Sender: TObject);
- var i: INTEGER;
- begin
- For i:=0 to 1 do
- begin
- rData2[i] := rData2[i] + 3 * (0.5 - random);
- end;
- ScrollXCtrl2.UpdateDynData(0,rData2[0]);
- end;
-
- procedure TForm1.ScrollXCtrl3OnInternalTimer(Sender: TObject);
- begin
- rData3[0] := rData3[0] + 2 * (0.5 - random);
- ScrollXCtrl3.UpdateDynData(0,rData3[0]);
-
- end;
-
- procedure TForm1.ScrollXCtrl4OnInternalTimer(Sender: TObject);
- var i: integer;
- begin
- For i:=0 to 3 do
- begin
- rData4[i] := rData4[i] + (0.5 - random);
- end;
- rData4[4] := 5 * random; // Random time interval
- ScrollXCtrl4.UpdateDynData(0,rData4[0]);
- end;
-
-
- procedure TForm1.ScrollXCtrl5OnInternalTimer(Sender: TObject);
- var
- rData: array[0..3] of double;
- rMin: double;
- rMax: double;
- rRange: double;
- rUpdateValue: double;
- i, nNumTraces: integer;
- begin
- nNumTraces := ScrollXCtrl5.SDataNumGroups[0] div 2;
- for i:=0 TO nNumTraces - 1 DO
- begin
- rUpdateValue := nUpdateCounter / 16.0;
- // X value for XY plot
- rData5[i] := 0.95 * 9.0 * sin ( rUpdateValue ) / 2;
- // Y value for XY plot
- rData5[i + nNumTraces] := 0.95 * 9.0 *
- sin(rUpdateValue *1.1 + 0.5 + i * rUpdateValue)/2;
- end;
- nUpdateCounter := nUpdateCounter + 1;
- ScrollXCtrl5.UpdateDynData (0, rData5[0]);
- end;
-
-
- end.
-